/**
 * Copyright ©2012-2018 HopeHaiyang Corporation, All Rights Reserved
 * http://www.wuhanhope.com
 */
package hujia.profile.server.img;

import hujia.profile.dao.UserRepository;
import hujia.profile.domain.User;
import hujia.profile.server.header.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Optional;

/**
 * class info
 *
 * @author hujia
 *         Create at 2018/7/31 9:46
 */
@Service
public class UserServiceImg implements UserService {

    @Autowired
    private UserRepository repository;

    @Override
    public Optional<User> getByUserName(String userName) {
        return repository.findByUserName(userName);
    }

    @Override
    public User add(User user) {
        user.setGmtModified(new Date());
        user.setGmtCreate(new Date());
        return repository.save(user);
    }
}
